package com.wy.about_data_share.demo3;

/**
 * @author 美女
 * @date 2022/04/21 22:43
 **/
public class Main {
    static int r=0;//定义为静态属性
    //进程中就这一个r
    static class MyThread extends Thread{
        @Override
        public void run() {
            for (int i = 0; i < 1000; i++) {
                r++;
            }
            System.out.println(getName()+":"+r);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t=new MyThread();
        t.start();
        t.join();
        System.out.println(Thread.currentThread().getName()+":"+r);
    }
}
